#include<bits/stdc++.h>
using namespace std;
int q;
struct SET1{
    priority_queue<int> q1, q2;
    void add(int x){
        q1.emplace(x);
    }
    void del(int x){
        q2.emplace(x);
    }
    int max(){
        while(q2.size() && q1.top() == q2.top())q1.pop(), q2.pop();
        if(!q1.size())return -1e9;
        return q1.top();
    }
}L, str[1000005];
struct SET2{
    priority_queue<int> q1, q2;
    void add(int x){
        q1.emplace(-x);
    }
    void del(int x){
        q2.emplace(-x);
    }
    int min(){
        while(q2.size() && q1.top() == q2.top())q1.pop(), q2.pop();
        if(!q1.size())return 1e9;
        return -q1.top();
    }
}R, stl[1000005];
struct node{
    int ans = 1e9, pre = -1e9, suf = 1e9;
}f[4000005];
void chg(int now, int l, int r, int x){
    if(l == r){
        f[now].pre = str[x].max();
        f[now].suf = stl[x].min();
        f[now].ans = 1e9;
        return;
    }
    int mid = l+r>>1;
    if(x <= mid)chg(now * 2, l, mid, x);
    else chg(now * 2 + 1, mid + 1, r, x);
    f[now].pre = max(f[now * 2].pre, f[now * 2 + 1].pre);
    f[now].suf = min(f[now * 2].suf, f[now * 2 + 1].suf);
    f[now].ans = min(min(f[now * 2].ans, f[now * 2 + 1].ans), f[now * 2 + 1].suf - f[now * 2].pre + 1);
}
signed main(){
    freopen("stone.in", "r", stdin);
    freopen("stone.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin >> q;
    while(q--){
        char ch;
        int x, y;
        cin >> ch >> x >> y;
        y--;
        if(ch == 'A')L.add(x), R.add(y), stl[x].add(y), str[y].add(x);
        else L.del(x), R.del(y), stl[x].del(y), str[y].del(x);
        chg(1, 1, 1e6, x), chg(1, 1, 1e6, y);
        if(L.max() <= R.min()){
            cout << stl[L.max()].min() - str[R.min()].max() + 1 << '\n';
        }else{
            cout << f[1].ans << '\n';
        }
    }
    return 0;
}